package com.hqyj.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description 扇形交换机配置
 * @Autor 伍军
 * @Date 2022/10/18 13:47
 * @Version 1.0
 **/
//@Configuration
public class MqFountConfig {
    /*---------------消息转换配置-----*/
    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }

    //创建队列fountQueue01
    @Bean
    public Queue fountQueue01(){
        return new Queue("fountQueue01",true);
    }
    //创建队列fountQueue02
    @Bean
    public Queue fountQueue02(){
        return new Queue("fountQueue02",true);
    }
    //创建队列fountQueue03
    @Bean
    public Queue fountQueue03(){
        return new Queue("fountQueue03",true);
    }

    //创建扇形交换机
    @Bean
    public FanoutExchange createFanoutExchange(){
        return  new FanoutExchange("createFanoutExchange");
    }

    //绑定fountQueue01队列
    @Bean
    public Binding bindFanoutExchange01(){
        return BindingBuilder.bind(fountQueue01()).to(createFanoutExchange());
    }
    //绑定fountQueue02队列
    @Bean
    public Binding bindFanoutExchange02(){
        return BindingBuilder.bind(fountQueue02()).to(createFanoutExchange());
    }
    //绑定fountQueue03队列
    @Bean
    public Binding bindFanoutExchange03(){
        return BindingBuilder.bind(fountQueue03()).to(createFanoutExchange());
    }


}
